package org.wheel.plugins.toolkit.sql.segment.having;

import lombok.RequiredArgsConstructor;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;

/**
 * ========== 4. 原子叶子节点（函数、比较、子查询） ==========
 */
@RequiredArgsConstructor
public final class HavingCondition implements HavingElement {
    private final String raw; // 已含 :pX 占位符

    @Override
    public Expression toExpression() {
        try {
            return CCJSqlParserUtil.parseExpression(raw);
        } catch (Exception e) {
            throw new RuntimeException("HAVING 表达式解析失败: " + raw, e);
        }
    }
}
